package com.supcon.exchangedata.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;

/**
 * @author ：icerain.gan
 * @date ：Created in 2020/3/11 13:41
 * @description：返回信息枚举
 * @modified By：
 * @version: 1.0$
 */

@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ResultEnum {

    SUCCESS("0", "返回成功"),
    DATA_IS_NONE("100", "数据为空"),
    ERROR("-1", "未知错误"),
    FAILED_VALIDATION("1100", "字段校验失败"),
    FAILED_INSPECTION("1200", "数据检查失败"),
    FAILED_LOGIC("1300", "逻辑判断失败"),
    FAILED_VALIDATE("1700","操作失败"),
    FAILED_SYSTEM("1900", "系统错误");

    private String code;
    private String message;

    ResultEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 提供枚举对象信息提示扩展
     * @param msg
     * @return
     */
    public ResultEnum appendMsg(String msg){
        StringBuilder str = new StringBuilder();
        str.append(msg);
        this.message = str.toString();
        return this;
    }

    /**
     * 枚举对线重新赋值
     * @param code
     * @param msg
     * @return
     */
    public ResultEnum setResultEnum(String code,String msg){
        this.code = code;
        this.message = msg;
        return this;
    }

}
